package sort;

import util.SortUtil;

import java.util.AbstractCollection;
import java.util.Random;

/**
 * Created by zk on 2016/1/9.
 */
public class InsertSort implements Sort{

    @Override
    public void doSort(int[] nums) {
        int len = nums.length;
        for (int i = 0; i < len; i++) {
            int temp = nums[i];
            int j = i - 1;
            while(j >= 0 && nums[j] > temp) {
                nums[j + 1] = nums[j];
                j--;
            }
            nums[j + 1] = temp;
        }
    }

    public static void main(String[] arg) {
        InsertSort insertSort = new InsertSort();
        SortUtil sortUtil = new SortUtil();
        sortUtil.sortRun(insertSort);
    }
}
